package com.sushi.service.impl;

import com.sushi.dao.BookDao;
import com.sushi.pojo.Book;
import com.sushi.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookServiceImpl implements BookService {
    @Autowired
    private BookDao bookDao;

    @Override
    public List<Book> findAll() {
        return bookDao.findAll();
    }

    @Override
    public Book findById(int id) {
        return bookDao.findById(id);
    }

    @Override
    public boolean save(Book book) {
//        return bookDao.save(book) > 0;
        System.out.println("保存一条数据");
        bookDao.save(book);
        return true;
    }

    @Override
    public boolean update(Book book) {
//        return bookDao.update(book) > 0;
        bookDao.update(book);
        return true;
    }

    @Override
    public boolean delete(int id) {
//        return bookDao.deleteById(id) > 0;
        bookDao.deleteById(id);
        return true;
    }
}
